home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / buzzwordBingo / bingo.c next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  6.8 KB  |  269 lines

  1. /* Buzzword Bingo
  2.  * 
  3.  * Don't use more than 4 words in each bingo phrase (that's
  4.  * 3 spaces).  As coded, the program takes an optional numeric
  5.  * parameter (with none given, it uses 1), and produces that
  6.  * many random bingo cardpairs.  It writes a file called bingo.ps,
  7.  * and sends it to the lp program.  To change that behavior, look
  8.  * at the final few lines in this file.  bingo.ps is in PostScript
  9.  * format.
  10.  * 
  11.  * Please distribute this program to anyone who "needs" it.
  12.  * 
  13.  * I've got an action item to fix the problems above, but I've got
  14.  * a lot of cutting edge problems on my plate, and my guesstimate
  15.  * is that I won't have time to work the issue before my drop dead
  16.  * date.  Buzzword bingo is only a 90% solution, so do the right thing,
  17.  * take the challenge, and make it happen.  The ball's in your court.
  18.  * 
  19.  * Tom Davis
  20.  * Silicon Graphics, Inc.
  21.  * February, 1993
  22.  * 
  23.  */
  24.  
  25. #include <time.h>
  26. #include <stdio.h>
  27.  
  28. FILE *f;
  29.  
  30. char *buzzwords[] = {
  31.     "90% Solution", 
  32.     "Action Item", 
  33.     "Alpha Release", 
  34.     "Attack The Problem", 
  35.     "Ball's In Your Court", 
  36.     "Bandwidth", 
  37.     "Big Win", 
  38.     "Bite The Bullet",
  39.     "Blows Them Away",  
  40.     "Challenge", 
  41.     "Close The Loop", 
  42.     "Collateral", 
  43.     "Context Switch", 
  44.     "Core Competency", 
  45.     "Critical Path", 
  46.     "Culture Change", 
  47.     "Customer Focus", 
  48.     "Cutting Edge", 
  49.     "Deliverables", 
  50.     "Dialog With (v.)", 
  51.     "Disincent", 
  52.     "Do The Right Thing", 
  53.     "Drop Dead Date", 
  54.     "Empowerment",
  55.     "Enterprise", 
  56.     "Execution", 
  57.     "Feedback", 
  58.     "First Class", 
  59.     "Focus, Focus, Refocus", 
  60.     "Functionality Freeze", 
  61.     "GUI", 
  62.     "Gating Factor", 
  63.     "Get Your Input", 
  64.     "Going Forward", 
  65.     "Gold Star", 
  66.     "Guesstimate", 
  67.     "Hot Button", 
  68.     "Impact (v.)", 
  69.     "Incent (v.)", 
  70.     "Interface", 
  71.     "Issue", 
  72.     "Key Players", 
  73.     "Kick-Ass Graphics", 
  74.     "Knock Your Socks Off", 
  75.     "Leading Edge", 
  76.     "Leverage", 
  77.     "Make It Happen",
  78.     "Massively Parallel", 
  79.     "Mind Blowing", 
  80.     "Mindshare",  
  81.     "Neophyte",
  82.     "Object Oriented", 
  83.     "Off Line", 
  84.     "On Board", 
  85.     "On Your Plate", 
  86.     "One On One", 
  87.     "Opportunity", 
  88.     "Paradigm Shift", 
  89.     "Pass The Baton", 
  90.     "Price Point", 
  91.     "Proactive", 
  92.     "Productized", 
  93.     "Raise A Flag", 
  94.     "Rathole", 
  95.     "Red Flag", 
  96.     "Reference (v.)", 
  97.     "Resolution", 
  98.     "Revolutionary", 
  99.     "Ride The Wave",  
  100.     "Sanity Check", 
  101.     "Scenarios", 
  102.     "Signage", 
  103.     "Sign Off On", 
  104.     "Skill Set", 
  105.     "Solutions", 
  106.     "Soup To Nuts", 
  107.     "Standard", 
  108.     "State Of The Art", 
  109.     "Step Up To It", 
  110.     "Sweet Spot", 
  111.     "Synergy", 
  112.     "Take Ownership", 
  113.     "Take The Initiative", 
  114.     "Talk To Issue", 
  115.     "Tangent", 
  116.     "Team Building", 
  117.     "Team Player", 
  118.     "Time Frame", 
  119.     "Touch Base", 
  120.     "Transition",
  121.     "Up To Speed", 
  122.     "User Friendly",  
  123.     "Utilize", 
  124.     "Wearing Different Hats", 
  125.     "Whatever It Takes", 
  126.     "Win-Win", 
  127.     "Working The Issue", 
  128.     "World Class", 
  129.     "WYSIWYG",
  130. };
  131.  
  132. long buzzlen = sizeof(buzzwords)/sizeof(long);
  133.  
  134. void centertext(long i, long j, long k)
  135. {
  136.     long spaces = 0;
  137.     char *s = buzzwords[k], *t;
  138.     while (*s) if (*s++ == ' ') spaces++;
  139.     switch (spaces) {
  140.     case 0:
  141.         fprintf(f, "%d %d (%s) centertext\n", i, j, buzzwords[k]);
  142.         break;
  143.     case 1:
  144.         s = t = buzzwords[k];
  145.         while (*s != ' ') s++;
  146.         *s = 0;
  147.         fprintf(f, "%d %d (%s) centertext\n", i, j+6, t);
  148.         *s = ' ';
  149.         fprintf(f, "%d %d (%s) centertext\n", i, j-6, s+1);
  150.         break;
  151.     case 2:
  152.         s = t = buzzwords[k];
  153.         while (*s != ' ') s++;
  154.         *s = 0;
  155.         fprintf(f, "%d %d (%s) centertext\n", i, j+12, t);
  156.         *s = ' ';
  157.         t = s+1; s++;
  158.         while (*s != ' ') s++;
  159.         *s = 0;
  160.         fprintf(f, "%d %d (%s) centertext\n", i, j, t);
  161.         *s = ' ';
  162.         fprintf(f, "%d %d (%s) centertext\n", i, j-12, s+1);
  163.         break;
  164.     case 3:
  165.         s = t = buzzwords[k];
  166.         while (*s != ' ') s++;
  167.         *s = 0;
  168.         fprintf(f, "%d %d (%s) centertext\n", i, j+18, t);
  169.         *s = ' ';
  170.         t = s+1; s++;
  171.         while (*s != ' ') s++;
  172.         *s = 0;
  173.         fprintf(f, "%d %d (%s) centertext\n", i, j+6, t);
  174.         *s = ' ';
  175.         t = s+1; s++;
  176.         while (*s != ' ') s++;
  177.         *s = 0;
  178.         fprintf(f, "%d %d (%s) centertext\n", i, j-6, t);
  179.         *s = ' ';
  180.         fprintf(f, "%d %d (%s) centertext\n", i, j-18, s+1);
  181.         break;
  182.     case 4:
  183.         fprintf(stderr, "Fucked up data -- more than 4 words\n");
  184.         exit(0);
  185.     }
  186. }
  187.  
  188. void gendata()
  189. {
  190.     long i, j, k;
  191.     long index[200];
  192.     
  193.     for (i = 0; i < 200; i++) index[i] = 0;
  194.     for (i = 36; i < 360; i += 72)
  195.     for (j = 36; j < 360; j += 72) {
  196.         if (i != 180 || j != 180) {
  197.         while (index[k = rand() % buzzlen] == 1) ;
  198.         centertext(i, j, k);
  199.         index[k] = 1;
  200.         }
  201.     }
  202. }
  203.  
  204. void dumpcard()
  205. {
  206. fprintf(f, "/centertext {\n");
  207. fprintf(f, "    dup stringwidth\n");
  208. fprintf(f, "    3 index exch sub\n");
  209. fprintf(f, "    exch 2 div 4 index exch sub exch\n");
  210. fprintf(f, "    moveto show pop pop\n");
  211. fprintf(f, "} bind def\n");
  212. fprintf(f, "gsave\n");
  213. fprintf(f, "90 rotate 18 -500 translate\n");
  214. fprintf(f, "/Times-Roman findfont 30 scalefont setfont\n");
  215. fprintf(f, "40 390 moveto (SGI Buzzword Bingo) show\n");
  216. fprintf(f, "/Times-Roman findfont 18 scalefont setfont\n");
  217. fprintf(f, "155 175 moveto (FREE) show\n");
  218. fprintf(f, "/Times-Roman findfont 10 scalefont setfont\n");
  219. fprintf(f, "0 -10 moveto (In meetings, mark squares as each buzzword is used.) show\n");
  220. fprintf(f, "0 -20 moveto (Use only buzzwords uttered by others.) show\n");
  221. gendata();
  222. fprintf(f, "0 72 360 {\n");
  223. fprintf(f, "    dup 0 moveto 360 lineto stroke\n");
  224. fprintf(f, "} for\n");
  225. fprintf(f, "0 72 360 {\n");
  226. fprintf(f, "    dup 0 exch moveto 360 exch lineto stroke\n");
  227. fprintf(f, "} for\n");
  228. fprintf(f, "grestore\n");
  229. fprintf(f, "gsave\n");
  230. fprintf(f, "90 rotate 414 -500 translate\n");
  231. fprintf(f, "/Times-Roman findfont 30 scalefont setfont\n");
  232. fprintf(f, "40 390 moveto (SGI Buzzword Bingo) show\n");
  233. fprintf(f, "/Times-Roman findfont 18 scalefont setfont\n");
  234. fprintf(f, "155 175 moveto (FREE) show\n");
  235. fprintf(f, "/Times-Roman findfont 10 scalefont setfont\n");
  236. fprintf(f, "0 -10 moveto (In meetings, mark squares as each buzzword is used.) show\n");
  237. fprintf(f, "0 -20 moveto (Use only buzzwords uttered by others.) show\n");
  238. gendata();
  239. fprintf(f, "0 72 360 {\n");
  240. fprintf(f, "    dup 0 moveto 360 lineto stroke\n");
  241. fprintf(f, "} for\n");
  242. fprintf(f, "0 72 360 {\n");
  243. fprintf(f, "    dup 0 exch moveto 360 exch lineto stroke\n");
  244. fprintf(f, "} for\n");
  245. fprintf(f, "grestore\n");
  246. fprintf(f, "showpage\n");
  247. }
  248.  
  249. main(int argc, char **argv)
  250. {
  251.     long cardcount, i;
  252.  
  253.     srand(time(0));
  254.     f = fopen("bingo.ps", "w");
  255.     if (argc == 2) {
  256.     cardcount = atoi(argv[1]);
  257.     } else {
  258.         cardcount = 1;
  259.     fprintf(stderr, "'bingo n' makes n pages\n");
  260.     }
  261.     fprintf(f, "%%!\n");
  262.     for (i = 0; i < cardcount; i++)
  263.     dumpcard();
  264.     fclose(f);
  265.     /*
  266.     system("lp bingo.ps");
  267.     */
  268. }
  269.